/* 
 * File:   PJLinkV1.h
 * Author: longtran
 *
 * Created on March 20, 2011, 2:10 AM
 */

#ifndef PJLINKV1_H
#define	PJLINKV1_H


#include "pjlinkv1code.h"

#include <QtCore/QMap>
#include <QtNetwork/QHostAddress>

namespace Projector
{

enum InfoMessage
{
    INFOMESSAGE_Protocol = 0,
    INFOMESSAGE_Security,
    INFOMESSAGE_RandomNumber
};

enum ResponseMessage
{
    RESPONSEMESSAGE_Command = 0,
    RESPONSEMESSAGE_Code
};


class PJLinkV1
{

QMap<QString, PJLinkV1Code*> mInputs;
QMap<QString, PJLinkV1Code*> mInputResponse;
QMap<QString, PJLinkV1Code*> mPowerStates;
QMap<QString, PJLinkV1Code*> mPowerStateResponse;

static const QString sHeaderPrefix;
static const QString sClassNumber;

static const QString sInputCmd;
static const QString sPowerCmd;

static const QString sPJLink;

static const int sPJLinkPort;


public:
    PJLinkV1();
    virtual ~PJLinkV1();

    PJLinkV1Code const* FindInput(const QString& input) const;
    PJLinkV1Code const* FindPowerStatus( const QString& powerState ) const;
    PJLinkV1Code const* FindInputResponse( const QString& response ) const;
    PJLinkV1Code const* FindPowerStateResponse( const QString& response ) const;

    bool TurnOn(const bool hasPassword, const QString& password, const QHostAddress& address) const;
    bool TurnOff(const bool hasPassword, const QHostAddress& address) const;

    bool SwitchInput( const QString& name ) const;

    bool BlackScreen() const;

    static QString CreateQuery( const QString& command, const QString& parameter);
    static QString CreatePasswordDigest( const QString& password, const QString& randomNumber );

};
}
#endif	/* PJLINKV1_H */

